#lang racket

(define (square x) (* x x))

(define (tree-map f tree)
  (map (lambda (x)
         (cond ((null? x) '())
               ((not (pair? x)) (f x))
               (else (tree-map f x)))) 
       tree))

(define (square-tree tree) (tree-map square tree))

(define x (list 1 (list 2 (list 3 4) 5) (list 6 7)))

(square-tree x)